package com.czkt.springboot_mybatis_test.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;

@Configuration
public class FilterRegister {

    @Resource
    StringRedisTemplate stringRedisTemplate;

    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        AutoFilter autoFilter = new AutoFilter();
        autoFilter.setRedisTemplate(stringRedisTemplate);
        registrationBean.setFilter(autoFilter);
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
